feat(time): support IANA time zones. close #14453 - #21739
Conversation
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. |
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds IANA time-zone support across time formatting utilities, time scales, and tooltips while preserving legacy useUTC behavior (deprecated) and keeping parsing semantics unchanged.
Changes:
- Introduces global
timeZoneoption and per-time-axistimeZoneoverride, with precedence overuseUTC. - Updates time utilities (
format,roundTime, tick/unit helpers) to operate in an IANA time zone and adds offset tokens ({Z},{ZZ}). - Threads axis/series time-zone context into tooltip markup generation and adds extensive unit tests for DST gaps/folds and performance.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/ut/spec/util/time.test.ts | Adds unit tests for time-zone-aware formatting, rounding, DST behavior, caching, and deprecated boolean overload warnings. |
| test/ut/spec/util/format.test.ts | Adds tests for makeValueReadable with time zones and legacy boolean behavior. |
| test/ut/spec/scale/time.test.ts | Adds integration tests for time-axis timeZone resolution, tick generation across DST, label formatting, and performance checks. |
| test/ut/spec/component/tooltip/timeZone.test.ts | Adds tooltip integration tests ensuring per-axis time zones are respected in markup and rendered tooltips. |
| src/util/types.ts | Adds global timeZone option and deprecates useUTC in option typing. |
| src/util/time.ts | Implements time-zone-aware formatting/rounding/unit detection and IANA offset calculations/caching via Intl.DateTimeFormat. |
| src/util/format.ts | Updates makeValueReadable to accept time-zone strings (and deprecates boolean). |
| src/scale/Time.ts | Moves tick generation and label formatting from useUTC to time-zone-aware logic. |
| src/model/Global.ts | Adds global time-zone resolution/storage (getTimeZone) with validation and precedence rules. |
| src/coord/axisHelper.ts | Resolves per-axis time zones (validated) when creating TimeScale. |
| src/coord/axisCommonTypes.ts | Adds timeZone?: string to time-axis options. |
| src/component/tooltip/tooltipMarkup.ts | Allows passing time-zone per value block and uses time-zone-aware readable formatting. |
| src/component/tooltip/seriesFormatTooltip.ts | Assigns an appropriate time zone per tooltip value based on the value’s axis scale. |
| src/component/tooltip/TooltipView.ts | Uses effective time zone when building tooltip markup and when formatting axis tooltips with string templates. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Brief Information
This pull request is in the type of:
What does this PR do?
Adds global and per-time-axis IANA time-zone support for ticks, labels, tooltips, and time utilities while preserving
useUTCcompatibility.Fixed issues
Details
Before: What was the problem?
Time axes could only use UTC or the browser/operating-system time zone. Charts could not select an IANA time zone or use different time zones for different axes.
After: How does it behave after the fixing?
Charts can define a global
timeZone, overridden bytimeZoneon individual time axes. Time-axis ticks, labels, and tooltip values use the effective axis time zone.The legacy
useUTCoption remains supported, andtimeZonetakes precedence when both are specified. Input parsing behavior is unchanged.The implementation uses native
Intl.DateTimeFormat, without external dependencies or a bundled time-zone database.Document Info
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
test/ut/spec/scale/time.test.tstest/ut/spec/util/time.test.tstest/ut/spec/util/format.test.tstest/ut/spec/component/tooltip/timeZone.test.tsValidation:
npm testnpm run checktypenpm run lintnpm run test:dts:fastMerging options
Other information
This PR builds on the work started in #21475, continuing it with a native
Intl.DateTimeFormatimplementation and completing global and per-axis time-zone support, backward compatibility, DST handling, tooltips, tests, and documentation.